# The name of the extension.
extension_name := nhnjapanpartnertoolbar

# The UUID of the extension.
extension_uuid := nhnjapanpartnertoolbar@nhn.org

# The name of the profile dir where the extension can be installed.
profile_dir := cc1y85fi.default

# The zip application to be used.
ZIP := zip

# The target location of the build and build files.
bin_dir := ../bin

# The target XPI file.
xpi_file := $(bin_dir)/$(extension_name).xpi

#profile_location := ~/Library/Application\ Support/Firefox/Profiles/$(profile_dir)/extensions/$(extension_uuid)/

firefox_version := 12.0
profile_location := ~/Desktop/All_Install_Firefox/$(firefox_version)/Profile/extensions/$(extension_uuid)/


# The temporary location where the extension tree will be copied and built.

build_dir := $(bin_dir)/build

# This builds the extension XPI file.
.PHONY: all
all: $(xpi_file)
	@echo
	@echo "Build finished successfully."
	@echo

# This cleans all temporary files and directories created by 'make'.
.PHONY: clean
clean:
	@rm -rf $(build_dir)
	@rm -f $(xpi_file)
	@echo "Cleanup is done."

# The sources for the XPI file.
xpi_built := install.rdf \
             chrome.manifest \
             $(wildcard content/*.js) \
             $(wildcard content/*.xul) \
             $(wildcard content/*.xml) \
             $(wildcard content/*.css) \
             $(wildcard skin/*.css) \
             $(wildcard skin/*.png) \
	     $(wildcard skin/*.ico) \
             $(wildcard locale/*/*.dtd) \
             $(wildcard locale/*/*.properties) \
	     $(wildcard modules/*.js) \
	     $(wildcard modules/*.jsm) \
	     $(wildcard defaults/preferences/*.js) \

xpi_built_all := install.rdf \
             chrome.manifest \
             content \
             skin \
             locale \
	     modules \
	     defaults \

# This builds everything except for the actual XPI, and then it copies it to the
# specified profile directory, allowing a quick update that requires no install.
.PHONY: install
install:
	@mkdir -p $(profile_location)
	@cp -Rf $(build_dir)/* $(profile_location)
	#@cp $(bin_dir)/nhnjapanpartnertoolbar.xpi $(profile_location)
	@echo "make install is done."
	
$(xpi_file): $(xpi_built)
	@echo "Creating XPI file."
	@$(ZIP) $(xpi_file) $(xpi_built)
	@mkdir -p $(build_dir)/
	@cp -R $(xpi_built_all) $(build_dir)/
	@echo "Creating XPI file. Done!"
